import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;


public class Employee extends JPanel implements ActionListener {
	
	private SystemEssentials gui = new SystemEssentials(1);
	private JCheckBox cView[] = new JCheckBox[7];
	private JComboBox cbFilterBy, cbStatus;
	public String[] sFilterBy = {"---", "Status", "Position", "Area", "Sections Handled"};
	public String[] sStatus = {"---", "Active", "Grades"};
	
	public Employee(){
		setLayout(null);
		setBounds(0,0,700,600);	
		setOpaque(false);

		refreshTable();
		createGui();		
	}
	
	public void createGui(){
		for(int i=0; i<7; i++){
			cView[i] = new JCheckBox();
			cView[i].addActionListener(this);
			cView[i].setSelected(true);
			switch(i){
			case 0: cView[i].setText("ID"); break;
			case 1: cView[i].setText("Status"); break;
			case 2: cView[i].setText("First Name"); break;
			case 3: cView[i].setText("Last Name"); break;
			case 4: cView[i].setText("Position"); break;
			case 5: cView[i].setText("Area"); break;
			case 6: cView[i].setText("Year Handled"); break;
			}
			cView[i].setBounds(25,440+(i*19),140,19);
			if(i==7)
				cView[7].setVisible(false);
			add(cView[i]);
		}
		
		cbFilterBy = new JComboBox(sFilterBy);
		cbFilterBy.setBounds(170,440,190,30);
		cbFilterBy.addActionListener(this);
		add(cbFilterBy);
		
		cbStatus = new JComboBox(sStatus);
		cbStatus.setBounds(170,480,190,30);
		add(cbStatus);
		
		add(gui);		
	}
		
	public void actionPerformed(ActionEvent a) {

	}
		
	public void refreshTable(){
		gui.resetTableModel(1);
		// for input data from sql
		for(int i=0; i<1; i++){
			Vector<String> rowData = new Vector<String>();
			//sample
			rowData.add("001");
			rowData.add("Active");
			rowData.add("Julius");
			rowData.add("Grandea");
			rowData.add("Coordinator");
			rowData.add("English");
			rowData.add("Fourth");
			//sample
			gui.model.addRow(rowData);
		}

		for(int i=0; i<gui.model.getColumnCount(); i++){
			gui.table.getColumnModel().getColumn(i).setCellRenderer(gui.cellRenderer);
			gui.setColumnWidth(i,1);
		}
		
		for(int i=0; i<1; i++){
			Vector<String> rowData = new Vector<String>();
			//sample
			rowData.add("002");
			rowData.add("Inactive");
			rowData.add("Dindo");
			rowData.add("Munsayac");
			rowData.add("Faculty");
			rowData.add("Science");
			rowData.add("Fourth");
			//sample
			gui.model.addRow(rowData);
		}

		for(int i=0; i<gui.model.getColumnCount(); i++){
			gui.table.getColumnModel().getColumn(i).setCellRenderer(gui.cellRenderer);
			gui.setColumnWidth(i,1);
		}
	}
		
	public void refreshGUI(){
		refreshTable();
		gui.refreshGUI();
	}
}
